package com.ukao.steward.adapter;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ukao.steward.R;
import com.ukao.steward.base.ListBaseAdapter;
import com.ukao.steward.base.SuperViewHolder;
import com.ukao.steward.bean.IncomeDetailbBean;
import com.ukao.steward.util.CheckUtils;
import com.ukao.steward.util.L;
import com.ukao.steward.util.MyDateUtils;

import java.util.List;


public class BalanceAdapter extends ListBaseAdapter<IncomeDetailbBean.ListBean> {



    int adapterType;


    public BalanceAdapter(Context context, List<IncomeDetailbBean.ListBean> mDataList,int adapterType ) {
        super(context, mDataList);
        this.adapterType= adapterType;

    }

    public int getLayoutId() {
        L.i("enterType=" + adapterType);
        if (adapterType == 0) {
            return R.layout.adapter_balance_layout_income;
        } else if (adapterType == 2) {
            return R.layout.adapter_balance_layout_income;
        } else {
            return R.layout.adapter_balance_layout;
        }
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, final int position) {
        IncomeDetailbBean.ListBean item = mDataList.get(position);
        switch (adapterType) {
            case 0:
                TextView orderNo = holder.getView(R.id.orderNo);
                TextView seq = holder.getView(R.id.seq);
                orderNo.setText(CheckUtils.isEmptyString(item.getOrderNo()));
                seq.setText(CheckUtils.isEmptyString(item.getSeq()));
                break;
            case 2:
                LinearLayout orderNoLayout = holder.getView(R.id.orderNo_layout);
                TextView seq1 = holder.getView(R.id.seq);
                orderNoLayout.setVisibility(View.GONE);
                seq1.setText(CheckUtils.isEmptyString(item.getSeq()));
                break;
           default:
               TextView tradeTypeText = holder.getView(R.id.tradeTypeText);
                tradeTypeText.setText(CheckUtils.isEmptyString(item.getTradeTypeText()));
                break;
        }

        TextView createTime = holder.getView(R.id.createTime);
        TextView income = holder.getView(R.id.income);
        createTime.setText(MyDateUtils.formatDataTime(item.getCreateTime()));
        int expenditure = item.getExpenditure();
        if (!CheckUtils.isNull(expenditure) && expenditure > 0) {/*扣钱*/
            income.setTextColor(getColors(R.color.red));
            income.setText("-" + CheckUtils.isEmptyNumber(item.getExpenditure()));
        } else {
            income.setText("+" + CheckUtils.isEmptyNumber(item.getIncome()));
            income.setTextColor(getColors(R.color.green));
        }
    }


}
